package unimelb.discussiontracker.twitter.data.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "HashTagRanking")
@NamedQueries(value = {
        @NamedQuery(name = "HashTagRanking.CountTopRankings", query = "SELECT COUNT(ranking) FROM HashTagRanking ranking WHERE ranking.topic.id = :topicId AND ranking.interval.id = :intervalId"),
        @NamedQuery(name = "HashTagRanking.FindByTagValueTopicAndIntervalId", query = "SELECT ranking FROM HashTagRanking ranking WHERE ranking.hashTag.value = :tagValue AND ranking.topic.id = :topicId AND ranking.interval.id = :intervalId"),
        @NamedQuery(name = "HashTagRanking.CountRankingsByUser", query = "SELECT COUNT(DISTINCT ranking) FROM HashTagRanking ranking, IN (ranking.hashTag.includingTweets) tweetAssoc WHERE tweetAssoc.tweet.owner.id = :userId AND ranking.topic.id = :topicId AND ranking.interval.id = :intervalId")})
public class HashTagRanking {

    @Id
    @GeneratedValue
    @Column(name = "Id")
    private long id;

    @ManyToOne
    @JoinColumn(name = "HashTagId")
    private HashTagEntity hashTag;

    @ManyToOne
    @JoinColumn(name = "TopicId")
    private TopicEntity topic;

    @ManyToOne
    @JoinColumn(name = "IntervalId")
    private IntervalEntity interval;

    @Column(name = "Strength")
    private int strength;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public HashTagEntity getHashTag() {
        return hashTag;
    }

    public void setHashTag(HashTagEntity hashTag) {
        this.hashTag = hashTag;
    }

    public TopicEntity getTopic() {
        return topic;
    }

    public void setTopic(TopicEntity topic) {
        this.topic = topic;
    }

    public IntervalEntity getInterval() {
        return interval;
    }

    public void setInterval(IntervalEntity interval) {
        this.interval = interval;
    }

    public int getStrength() {
        return strength;
    }

    public void setStrength(int strength) {
        this.strength = strength;
    }

}
